package synchro;

import java.io.*;
import java.util.Date;

/**
 * @author DELL
 * @create 2017-09-22 17:40
 */
public class LogFile {
    private Writer out;
    private File f;

    public LogFile(File f) throws IOException {
        this.f = f;
        FileWriter fw = new FileWriter(f);
        this.out = new BufferedWriter(fw);
    }

    public void writeEntry(String message) throws IOException {
        Date d = new Date();
        out.write(message + ":" + d.toString());
        out.write('\t');
        out.write(message);
        out.write("\r\n");
    }
    /*public void writeEntry(String message) throws IOException {
        synchronized (out) {
            Date d = new Date();
            out.write(message + ":" + d.toString());
            out.write('\t');
            out.write(message);
            out.write("\r\n");
        }
    }*/

    public void close() throws IOException {
        out.flush();
        out.close();
    }
}
